
$(function () {
    findById();
});

function findById() {
    let id = sessionStorage.getItem("dailyId");
    let result = myAjax("/api/dw/daily/findById", {id: id}, "post");
    if (result != null) {
        setData(result.data);
    }
}

function setData(data) {
    $("#author").val(data.author);
    $("#time").val(data.time);
    $("#major").val(data.major);
    $("#coach").val(data.coach);
    $("#councilor").val(data.councilor);
    $("#content").val(data.content);
    $("#event").val(data.event);
    $("#starred").val(data.starred);
    $("#harvest").val(data.harvest);
    $("#doubt").val(data.doubt);
    $("#help").val(data.help);
}

/**
 * 提交检查
 */
function check() {
    let dailyStatus = sessionStorage.getItem("dailyStatus");
    if(dailyStatus === "已提交"){
        let data = {
            id: sessionStorage.getItem("dailyId"),
            status: "已检查"
        };
        let result = myAjax("/api/dw/daily/updateStatus", data, "post");
        if (result) {
            layer.alert(result.message, {icon: 1});
            x_admin_close();
            x_admin_father_reload();
            // location.href="javascript:location.replace(location.href);"
        } else {
            layer.alert(result.message, {icon: 2});
            // location.href="javascript:location.replace(location.href);"
        }
    }else{
        alert("学员未提交日报")
    }

}